1 Prepare Transaction Data

We begin by loading our prepared AAVE transaction data into a dataframe. The dataset has over 400,000 rows, and 27 columns.

We are directly loading the dataframe from an Rds archive instead of a CSV file to conserve space.

#load Rds (binary version of csv file) into dataframe
df<-read_rds('../../Data/transactions.Rds')

For readability in the future let’s add a column to the data with the datetimes of each transaction.

df <- df %>%
  mutate(datetime = as_datetime(timestamp))

2 Analyze Swap Data:

First we select the columns from the dataframe that are relevant to Swap transactions.

borrowRateSwaps <- df %>%
  filter(type == 'swap') %>%
  select(borrowRateModeFrom, borrowRateModeTo, reserve, variableBorrowRate, stableBorrowRate) %>%
  group_by(borrowRateModeFrom) %>%
  mutate(vsRatio = variableBorrowRate/stableBorrowRate)

Next let’s separate the data into two charts: (1) Swaps from Variable to Stable; and (2) Swaps from Stable to Variable:

variableSwaps <- borrowRateSwaps %>%
  filter(borrowRateModeFrom == 'Variable')

varToStable <- ggplot(variableSwaps, aes(variableBorrowRate, stableBorrowRate)) +
  geom_point(aes(color = reserve)) +
  ggtitle("At What Rates are Users Swapping from Variable to Stable Borrows?") +
  geom_abline(slope = 1, intercept = 0)
ggplotly(varToStable)
stableSwaps <- borrowRateSwaps %>%
  filter(borrowRateModeFrom  == 'Stable')

stableToVar <- ggplot(stableSwaps, aes(stableBorrowRate, variableBorrowRate)) +
  geom_point(aes(color = stableSwaps$reserve)) +
  ggtitle("At What Rates are Users Swapping from Stable to Variable Borrows?") +
  geom_abline(slope = 1, intercept = 0)
ggplotly(stableToVar)

We see in each of the above two charts that there are seemingly distinct lines at which users tend to swap borrow rates. In chart (1), users exclusively swap from variable to stable borrow rates when the ratio of stable to variable is greater than 1. This means they are swapping to a higher borrow rate.

In contrast, the second chart shows users swapping from stable borrow rates to variable borrow rates when the variable borrow rate is lower than the stable rate. This makes intuitive sense, since paying a lower interest rate on a loan is obviously beneficial. The more interesting part of the second chart is mainly that we again see distinct lines forming in the data.

3 Analyze Stable Borrow Rates Over Time:

From the above two charts it looks like the reserves USDT, USDC, and DAI comprise most of the swaps. Let’s limit the scope of the following analysis to those three reserves, at least for now, and look at the borrow rates of the these reserves over time.

First let’s filter out all but these three reserves and chart their respective Stable Borrow Rates over time:

borrowsUSDT <- df %>%
  filter(type=='borrow', reserve == 'USDT' | reserve == 'USDC' | reserve == 'DAI')

stableBorrowsUSDT <- borrowsUSDT %>%
  filter(borrowRateMode == 'Stable')

stableRatesOverTime <- ggplot(stableBorrowsUSDT, aes(datetime, borrowRate)) +
  geom_point(aes(color = reserve)) + 
  ggtitle("How do the Stable Borrow Rates of USDT, USDC, and DAI Change Over Time?")

ggplotly(stableRatesOverTime)

Much like in the previous two charts, we see these three reserves exhibiting very similar behavior. The stable borrow rates are clearly volatile, but it’s interesting to see that there are definite lines that act as a floor at any given time for the stable borrow rates, and this “floor” seems to increase periodically. At a glance there seem to be three distinct “steps” for this floor. With no way to confirm this hypothesis yet, it would make some sense if each of these steps correspond to one of the distinct lines of swaps in the previous chart.

4 Analyze Variable Borrow Rates Over Time:

Seeing interesting behavior in the stable borrow rates over time, it’s worthwhile to look at the variable borrow rates as well to see whether they follow a similar trend:

variableBorrowsUSDT <- borrowsUSDT %>%
  filter(borrowRateMode == 'Variable')

varRatesOverTime <- ggplot(variableBorrowsUSDT, aes(as_datetime(timestamp), borrowRate)) +
  geom_point(aes(color = reserve)) + 
  ggtitle("Variable Borrow Rates Over Time (USDT)")

ggplotly(varRatesOverTime)

Here we can see similarly chaotic behavior to the stable borrow rates and the presence of a sort of “floor” to the variable borrow rates. However, the floor seems very consistent. We don’t see it periodically increasing like we did with the stable borrow rates.

5